<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
    <div id="app">
        <!-- 使用自定义颜色指令 v-color -->
        <div v-color="'red'">这是一个标题</div>
        <!-- 使用自定义raaper 指令 v-rapper -->
        <div v-rapper="'尤雨溪 rapper'"></div>
    </div>
    <script src="./js/vue@3.5.13.js"></script>
    <script src="./js/axios.js"></script>
    <script>
        const { createApp, onMounted, ref } = Vue
        const app = createApp({
            setup() {
                return {}
            }
        })

        // 全局注册
        app.directive('color', {    // 自定义颜色指令
            // el 获取 dom 元素
            mounted(el, binding) {
                el.style.color = binding.value
                el.style.fontWeight = 'bolder'
            }
        })
        app.directive('rapper', {   // 自定义raaper 指令
            mounted(el, binding) {
                el.innerText = binding.value
            }
        })
        app.mount("#app") // 挂载容器(最后)
    </script>
</body>

</html>